//
//  RMMHomeTableViewCell.m
//  Romomo
//
//  Created by puman on 16/10/8.
//  Copyright © 2016年 mazegong. All rights reserved.
//

#import "RMMHomeTableViewCell.h"

@implementation RMMHomeTableViewCell
{
    UIImageView *_imageV;
    UILabel *_titleLabel;
    UILabel *_priceLabel;
    UILabel *_countLabel;
    UIButton *_goodBut;
    UILabel *_noValueLabel;
    UIImageView *_zhanImageV;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        _imageV = [[UIImageView alloc] initWithFrame:CGRectMake(15, 12, kScreenWideth - 30, kScreenWideth / 2 - 15)];
        _imageV.layer.cornerRadius = 5;
        [self.contentView addSubview:_imageV];
        
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, _imageV.bottom + 8, _imageV.width, 60)];
        _titleLabel.numberOfLines = 0;
        _titleLabel.textColor = COLORFROMCODE(0x303137, 1);
        _titleLabel.font = kFont(14);
        [self.contentView addSubview:_titleLabel];
        
        _priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(_titleLabel.left, _titleLabel.bottom , 80, 30)];
        _priceLabel.textColor = COLORFROMCODE(0x4A4A4A, 1);
        _priceLabel.font = kFont(18);
        [self.contentView addSubview:_priceLabel];
        
        _countLabel = [[UILabel alloc] initWithFrame:CGRectMake(_priceLabel.right + 12, _titleLabel.bottom , 70, 30)];
        _countLabel.textColor = COLORFROMCODE(0x53C7C6, 1);
        _countLabel.font = kFont(10);
        [self.contentView addSubview:_countLabel];
        
        _goodBut = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _goodBut.frame = CGRectMake(_countLabel.right + 3, _countLabel.top + 8, 14, 14);
        [_goodBut setBackgroundImage:[UIImage imageNamed:@"recommend@3x"] forState:(UIControlStateNormal)];
        _goodBut.userInteractionEnabled = NO;
        [self.contentView addSubview:_goodBut];
        
        _shopBut = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _shopBut.frame = CGRectMake(_titleLabel.right - 54, _titleLabel.bottom + 7, 54, 28);
        [self.contentView addSubview:_shopBut];
        
    }
    return self;
}
- (void)setModel:(RMMHomeGoodsModel *)model{
    [_imageV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kBaseImageUrl,model.IMAGEURL]] placeholderImage:[UIImage imageNamed:@"加载中@3x"]];
    _titleLabel.text = [NSString stringWithFormat:@"[%@]%@",model.NAME,model.IMAGE_SHOW_DESCRIBE];
    _priceLabel.text = [NSString stringWithFormat:@"¥ %@",model.PRICE];
    _countLabel.text = [NSString stringWithFormat:@"%@人点赞",model.PRAISE_COUNT];
    CGFloat width = [UILabel backHeightWithString:_countLabel.text CGFloatCount:30 metho:WIDTH font:10];
    _countLabel.frame = CGRectMake(_priceLabel.right + 12, _titleLabel.bottom, width, 30);
    _goodBut.frame = CGRectMake(_countLabel.right + 3, _countLabel.top + 8, 14, 14);
    NSString *bom_id = model.BOM_ID;
    if (bom_id.length > 0) {
        [_shopBut setBackgroundImage:[UIImage imageNamed:@"购买套餐@3x"] forState:(UIControlStateNormal)];
        _goodBut.hidden = YES;
        _countLabel.hidden = YES;
    } else {
        [_shopBut setBackgroundImage:[UIImage imageNamed:@"加购物车@2x"] forState:(UIControlStateNormal)];
        _goodBut.hidden = NO;
        _countLabel.hidden = NO;
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
